<?php
/**
 * 入口文件
 * 定义常量
 * 是否开启调试
 * 加载函数库
 */
date_default_timezone_set('PRC');

define('PHPLESS',APP.'/phpless');

define('PUBLIC_PATH',APP.'/Public');
define('UPLOADS_PATH',APP.'/Uploads');

define('APP_MODEL_PATH',APP_PATH.'/Model');
define('APP_VIEW_PATH',APP_PATH.'/View');
define('APP_CONTROLLER_PATH',APP_PATH.'/Controller');
define('APP_COMMON_PATH',APP_PATH.'/Common');

define('APP_CONFIG_PATH',APP_COMMON_PATH.'/Config');
define('APP_FUNCTION_PATH',APP_COMMON_PATH.'/Function');
define('APP_TRAIT_PATH',APP_COMMON_PATH.'/Traits');
define('APP_ORG_PATH',APP_COMMON_PATH.'/ORG');
define('APP_VENDOR_PATH',APP_COMMON_PATH.'/Vendor');

define('PHPLESS_CONFIG',PHPLESS.'/Config');
define('PHPLESS_FUNCTION',PHPLESS.'/Function');
define('PHPLESS_CORE',PHPLESS.'/core');
define('PHPLESS_ORG',PHPLESS.'/ORG');
define('PHPLESS_TEMPLATE',PHPLESS.'/Template');
define('PHPLESS_TRAIT',PHPLESS.'/Traits');
define('PHPLESS_VENDOR',PHPLESS.'/Vendor');

define('__HOST__',isset($_SERVER['REQUEST_SCHEME'])?$_SERVER['REQUEST_SCHEME'].'://'.dirname($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']):'http'.'://'.dirname($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']));
define('__PUBLIC__',__HOST__.'/Public');
define('__UPLOADS__',__HOST__.'/Uploads');
// 检测是否开启debug
if(APP_DEBUG){
    ini_set('display_errors','On');
}else{
    ini_set('display_errors','Off');
}

// 加载函数库
include PHPLESS_FUNCTION.'/functions.php';

// 自动加载类库
include PHPLESS_CORE.'/Autoloader.class.php';
// 使用 SPL 自动加载所需的类文件
spl_autoload_register('\phpless\core\Autoloader::load');
\phpless\core\Phpless::run();
